package com.example.camerademo.camera1;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.SurfaceView;

/**
 * @author ypk
 * 创建日期：2021/11/9  12:02
 * 描述：
 */
public class CustomSurfaceView extends SurfaceView {
    public CustomSurfaceView(Context context) {
        super(context);
    }

    public CustomSurfaceView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CustomSurfaceView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public void setCustomEvent(ONTouchEvent mONTouchEvent) {
        this.mONTouchEvent = mONTouchEvent;
    }

    public ONTouchEvent mONTouchEvent;

    public interface ONTouchEvent {
        void onTouchEvent(MotionEvent event);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (mONTouchEvent != null) {
            mONTouchEvent.onTouchEvent(event);
        }
        return super.onTouchEvent(event);
    }
}
